
using System;
using System.Data;
using System.Text;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using PuntoMascotasWeb.BackEnd.BE;

namespace PuntoMascotasWeb.BackEnd.DAC
{
  /// <summary>
  /// TableDataGateway para DetalleEstadia.
  /// </summary>
  /// <Date>2013-05-05T15:02:35</Date>
  /// <Author>Mx23</Author>
  public class DetalleEstadiaDAC
  {
    /// <summary>
    /// Insert
    /// </summary>
    /// <param name="pDetalleEstadiaBE">DetalleEstadiaBE</param>
    /// <returns>void</returns>
    /// <Date>2013-05-05T15:02:35</Date>
    /// <Author>Mx23</Author>
    public static void Insert(DetalleEstadiaBE pDetalleEstadiaBE)
    {
      Database wDataBase = null;
      DbCommand wCmd = null;

      try
      {
        wDataBase = DatabaseFactory.CreateDatabase("cnnPuntoMascotasWeb");
        wCmd = wDataBase.GetStoredProcCommand("DetalleEstadia_i");

        /// IdEstadia
        wDataBase.AddInParameter(wCmd, "IdEstadia", System.Data.DbType.Int32, pDetalleEstadiaBE.IdEstadia);
        /// IdUsosEstadia
        wDataBase.AddInParameter(wCmd, "IdUsosEstadia", System.Data.DbType.Int32, pDetalleEstadiaBE.IdUsosEstadia);
        /// Costo
        wDataBase.AddInParameter(wCmd, "Costo", System.Data.DbType.Decimal, pDetalleEstadiaBE.Costo);

        wDataBase.ExecuteNonQuery(wCmd);

      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        wCmd.Dispose();
        wCmd = null;
        wDataBase = null;
      }
    }/// <summary>
    /// Update
    /// </summary>
    /// <param name="pDetalleEstadiaBE">DetalleEstadiaBE</param>
    /// <returns>void</returns>
    /// <Date>2013-05-05T15:02:35</Date>
    /// <Author>Mx23</Author>
    public static void Update(DetalleEstadiaBE pDetalleEstadiaBE)
    {
      Database wDataBase = null;
      DbCommand wCmd = null;

      try
      {
        wDataBase = DatabaseFactory.CreateDatabase("cnnPuntoMascotasWeb");
        wCmd = wDataBase.GetStoredProcCommand("DetalleEstadia_u");

        /// IdEstadia
        wDataBase.AddInParameter(wCmd, "IdEstadia", System.Data.DbType.Int32, pDetalleEstadiaBE.IdEstadia);
        /// IdUsosEstadia
        wDataBase.AddInParameter(wCmd, "IdUsosEstadia", System.Data.DbType.Int32, pDetalleEstadiaBE.IdUsosEstadia);
        /// Costo
        wDataBase.AddInParameter(wCmd, "Costo", System.Data.DbType.Decimal, pDetalleEstadiaBE.Costo);

        wDataBase.ExecuteNonQuery(wCmd);

      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        wCmd.Dispose();
        wCmd = null;
        wDataBase = null;
      }
    }/// <summary>
    /// Delete
    /// </summary>
    /// <param name="pIdEstadia">IdEstadia</param>/// <param name="pIdUsosEstadia">IdUsosEstadia</param>
    /// <returns>void</returns>
    /// <Date>2013-05-05T15:02:35</Date>
    /// <Author>Mx23</Author>
    public static void Delete(System.Int32 pIdEstadia, System.Int32 pIdUsosEstadia)
    {
      Database wDataBase = null;
      DbCommand wCmd = null;

      try
      {
        wDataBase = DatabaseFactory.CreateDatabase("cnnPuntoMascotasWeb");
        wCmd = wDataBase.GetStoredProcCommand("DetalleEstadia_d");

        /// IdEstadia
        wDataBase.AddInParameter(wCmd, "IdEstadia", System.Data.DbType.Int32, pIdEstadia);
        /// IdUsosEstadia
        wDataBase.AddInParameter(wCmd, "IdUsosEstadia", System.Data.DbType.Int32, pIdUsosEstadia);

        wDataBase.ExecuteNonQuery(wCmd);

      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        wCmd.Dispose();
        wCmd = null;
        wDataBase = null;
      }
    }/// <summary>
    /// GetAll
    /// </summary>

    /// <returns>DataSet</returns>
    /// <Date>2013-05-05T15:02:35</Date>
    /// <Author>Mx23</Author>
    public static DataSet GetAll()
    {
      Database wDataBase = null;
      DbCommand wCmd = null;

      try
      {
        wDataBase = DatabaseFactory.CreateDatabase("cnnPuntoMascotasWeb");
        wCmd = wDataBase.GetStoredProcCommand("DetalleEstadia_s");


        return wDataBase.ExecuteDataSet(wCmd);
      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        wCmd.Dispose();
        wCmd = null;
        wDataBase = null;
      }
    }/// <summary>
    /// GetByParam
    /// </summary>

    /// <returns>DataSet</returns>
    /// <Date>2013-05-05T15:02:35</Date>
    /// <Author>Mx23</Author>
    public static DataSet GetByParam(int pPageNum, int pPageSize)
    {
      Database wDataBase = null;
      DbCommand wCmd = null;

      try
      {
        wDataBase = DatabaseFactory.CreateDatabase("cnnPuntoMascotasWeb");
        wCmd = wDataBase.GetStoredProcCommand("DetalleEstadia_sp");


        /// pPageNum
        wDataBase.AddInParameter(wCmd, "PageNum", System.Data.DbType.Int32, pPageNum);
        /// PageSize
        wDataBase.AddInParameter(wCmd, "PageSize", System.Data.DbType.Int32, pPageSize);

        return wDataBase.ExecuteDataSet(wCmd);

      }
      catch (Exception ex)
      {
        throw ex;
      }
      finally
      {
        wCmd.Dispose();
        wCmd = null;
        wDataBase = null;
      }
    }
  }
}